package service.impl;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import pojo.User;
import service.UserManager;

public class UserManagerImpl implements UserManager {

	@Override
	public User getUser(String name, Connection conn) {

		String sql="select * from users where uname=?";
		ResultSet rs=null;
		User u=new User();
		try {
			PreparedStatement pst=conn.prepareStatement(sql);
			pst.setString(1, name);
			rs=pst.executeQuery();
			if (rs.next()) {
				u.setId(rs.getInt("u_id"));
				u.setName(rs.getString("uname"));
				u.setPsd(rs.getString("upsd"));
			}
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}	
		return u;		
	
	}

}
